home *** CD-ROM | disk | FTP | other *** search
- {****************************************************}
- { CAboutBox.p}
- {}
- { The AboutBox Class}
- {}
- { SUPERCLASS = CDirector}
- {}
- { Copyright ⌐ 1989, Symantec Corporation. All rights reserved. }
- {}
- {****************************************************}
-
- unit CAboutBox;
-
- interface
-
- uses
- TCL, MoreTCL, ArtClassIntf;
-
- type
- BytePoint = record
- h: SignedByte;
- v: SignedByte;
- end;
-
- BytePointP = ^BytePoint;
- BytePointH = ^BytePointP;
-
-
- {** Class Constants **}
-
- const
- WIND_ABOUT = 2000;
- xBytePoints = (maxint div sizeof(BytePoint)) - 1;
-
- type
- BytePointArray = array[0..xBytePoints] of BytePoint;
- BytePointArrayP = ^BytePointArray;
- BytePointArrayH = ^BytePointArrayP;
-
-
- implementation
-
-
-
- {*** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ***}
-
-
-
- {****************************************************}
- { IAboutBox}
- {}
- { Initialize an AboutBox object}
- {}
- {****************************************************}
-
- procedure CAboutBox.IAboutBox (aSupervisor: CApplication);
- var
- theWindow: CWindow; { Altered by TCL Weaver 1.0 (5/9/90) }
-
- begin
- IDirector(aSupervisor);
-
- if ColorQDIsPresent then
- begin
- new(CColorWindow(theWindow)); { Altered by TCL Weaver 1.0 (5/9/90) }
- itsWindow := theWindow;
- CColorWindow(itsWindow).IColorWindow(WIND_ABOUT, TRUE, gDesktop, SELF);
- end
- else
- begin
- new(theWindow); { Altered by TCL Weaver 1.0 (5/9/90) }
- itsWindow := theWindow;
- itsWindow.IWindow(WIND_ABOUT, TRUE, gDesktop, SELF);
- end;
-
- blackboard := GetPicture(2000); { Load in resources }
- flatEraser := GetPicture(2001);
- rightEraser := GetPicture(2002);
- leftEraser := GetPicture(2003);
- wink := GetPicture(2004);
- acHVof := GetResource('HVof', 1);
- ghdHVof := GetResource('HVof', 2);
- gthHVof := GetResource('HVof', 3);
-
- gDecorator.CenterWindow(itsWindow);
-
- Display;
- end;
-
-
- {****************************************************}
- { Free (OVERRIDE)}
- {}
- { Dispose of AboutBox by releasing all its resources}
- {}
- {****************************************************}
-
- procedure CAboutBox.Free;
- begin
- ReleaseResource(Handle(blackboard));
- ReleaseResource(Handle(flatEraser));
- ReleaseResource(Handle(rightEraser));
- ReleaseResource(Handle(leftEraser));
- ReleaseResource(Handle(wink));
- ReleaseResource(Handle(acHVof));
- ReleaseResource(Handle(ghdHVof));
- ReleaseResource(Handle(gthHVof));
-
- inherited Free;
- end;
-
-
- {****************************************************}
- { Display}
- {}
- { Display contents of About Box. There's a lot of ugly code here and}
- { hard-wired values.}
- {}
- {****************************************************}
-
- function MouseOrKey (duration: longint): Boolean;
-
- {Kill time for the specified duration, in ticks. }
- {Exit early if the mouse is clicked or a key is pressed. }
-
- type
- fourLongs = record
- one, two, three, four: longint;
- end;
-
- var
- startTicks: longint;
- macKeyMap: KeyMap;
- allKeys: fourLongs;
-
- begin
- startTicks := TickCount;
-
- while (TickCount - startTicks) < duration do
- begin
- GetKeys(macKeyMap);
- macKeyMap[57] := false; {We want to show the about box }
- {even if Caps Lock is down. }
- macKeyMap[127] := false; {The Reset key causes trouble for some }
- {reason. }
- allKeys := fourLongs(macKeyMap);
- if Button or (allKeys.one <> 0) or (allKeys.two <> 0) or (allKeys.three <> 0) or (allKeys.four <> 0) then
- begin
- MouseOrKey := TRUE;
- Exit(MouseOrKey);
- end;
- end;
-
- MouseOrKey := FALSE;
- end;
-
-
- procedure CAboutBox.Display;
- var
- fBlackboard, fFlatEraser, fRightEraser, fLeftEraser, fWink, eraseClip, r, theRect: Rect;
- i: integer;
- n: integer;
- theHVof: Handle;
- off: BytePointArrayH;
- chalkColor: RGBColor;
-
- begin
- itsWindow.Select;
- itsWindow.Prepare;
- SetOrigin(-12, -12);
-
- fBlackboard := blackboard^^.picFrame;
- fFlatEraser := flatEraser^^.picFrame;
- OffsetRect(fFlatEraser, 250, 142);
- fRightEraser := rightEraser^^.picFrame;
- fLeftEraser := leftEraser^^.picFrame;
- fWink := wink^^.picFrame;
- OffsetRect(fWink, 51, 111);
-
- r := theRect;
-
- DrawPicture(blackboard, fBlackboard);
- DrawPicture(flatEraser, fFlatEraser);
- SetRect(eraseClip, 40, 32, 288, 108);
-
- if ColorQDIsPresent then
- begin
- {$PUSH}
- {$R-}
- chalkColor.red := 65281;
- chalkColor.green := 65281;
- chalkColor.blue := 52225;
- {$POP}
- RGBForeColor(chalkColor);
- RGBBackColor(chalkColor);
- end
- else
- ForeColor(whiteColor);
-
- while TRUE do
- begin
- if MouseOrKey(20) then
- Exit(Display);
-
- SetRect(r, 80, 40, 82, 42);
- n := integer(GetHandleSize(acHVof) div sizeof(BytePoint));
- off := BytePointArrayH(acHVof);
-
- for i := 0 to n - 1 do
- begin
- OffsetRect(r, off^^[i].h, off^^[i].v);
- PaintRect(r);
- if MouseOrKey(2) then
- Exit(Display);
- end;
-
-
- if MouseOrKey(60) then
- Exit(Display);
- ClipRect(fFlatEraser);
- DrawPicture(blackboard, fBlackboard);
- if MouseOrKey(30) then
- Exit(Display);
-
- ClipRect(fBlackboard);
- OffsetRect(fRightEraser, 60 - fRightEraser.left, 12 - fRightEraser.top);
- DrawPicture(rightEraser, fRightEraser);
-
- for i := 0 to 64 do
- begin
- OffsetRect(fRightEraser, 3, 1);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- for i := 0 to 8 do
- begin
- OffsetRect(fRightEraser, 0, 3);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- fLeftEraser := fRightEraser;
- DrawPicture(leftEraser, fLeftEraser);
- for i := 0 to 64 do
- begin
- OffsetRect(fLeftEraser, -3, -1);
- DrawPicture(leftEraser, fLeftEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- ClipRect(fLeftEraser);
- DrawPicture(blackboard, fBlackboard);
- if MouseOrKey(30) then
- Exit(Display);
- ClipRect(fBlackboard);
- DrawPicture(flatEraser, fFlatEraser);
- if MouseOrKey(30) then
- Exit(Display);
-
- n := integer(GetHandleSize(ghdHVof) div sizeof(BytePoint));
- off := BytePointArrayH(ghdHVof);
-
- SetRect(r, 90, 35, 92, 37);
- for i := 0 to n - 1 do
- begin
- OffsetRect(r, off^^[i].h, off^^[i].v);
- PaintRect(r);
- if MouseOrKey(2) then
- Exit(Display);
- end;
-
- if MouseOrKey(60) then
- Exit(Display);
- ClipRect(fFlatEraser);
- DrawPicture(blackboard, fBlackboard);
- if MouseOrKey(30) then
- Exit(Display);
-
- ClipRect(fBlackboard);
- OffsetRect(fRightEraser, 70 - fRightEraser.left, 12 - fRightEraser.top);
- DrawPicture(rightEraser, fRightEraser);
-
- for i := 0 to 64 do
- begin
- OffsetRect(fRightEraser, 3, 1);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- for i := 0 to 8 do
- begin
- OffsetRect(fRightEraser, 0, 3);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- fLeftEraser := fRightEraser;
- DrawPicture(leftEraser, fLeftEraser);
- for i := 0 to 64 do
- begin
- OffsetRect(fLeftEraser, -3, -1);
- DrawPicture(leftEraser, fLeftEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- fRightEraser := fLeftEraser;
- DrawPicture(rightEraser, fRightEraser);
- for i := 0 to 8 do
- begin
- OffsetRect(fRightEraser, 0, 3);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- for i := 0 to 25 do
- begin
- OffsetRect(fRightEraser, 3, 1);
- DrawPicture(rightEraser, fRightEraser);
- if MouseOrKey(1) then
- Exit(Display);
- end;
-
- ClipRect(fRightEraser);
- DrawPicture(blackboard, fBlackboard);
- if MouseOrKey(30) then
- Exit(Display);
- ClipRect(fBlackboard);
- DrawPicture(flatEraser, fFlatEraser);
- if MouseOrKey(30) then
- Exit(Display);
-
- n := integer(GetHandleSize(gthHVof) div sizeof(BytePoint));
- off := BytePointArrayH(gthHVof);
-
- SetRect(r, 45, 35, 47, 37);
- for i := 0 to n - 1 do
- begin
- OffsetRect(r, off^^[i].h, off^^[i].v);
- PaintRect(r);
- if MouseOrKey(2) then
- Exit(Display);
- end;
-
- if MouseOrKey(40) then
- Exit(Display);
- ClipRect(fWink);
- DrawPicture(wink, fWink);
- if MouseOrKey(20) then
- Exit(Display);
- DrawPicture(blackboard, fBlackboard);
- if MouseOrKey(150) then
- Exit(Display);
- ClipRect(eraseClip);
- DrawPicture(blackboard, fBlackboard);
- end;
- end;
-
-
- end.